feat(cli): add shell completion support#974
feat(cli): add shell completion support#974nekomoyi wants to merge 8 commits intovoidzero-dev:mainfrom
Conversation
✅ Deploy Preview for viteplus-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Looking into the CI failure. |
|
There is a bug in the |
|
@nekomoyi can you rebase and fix conflicts? |
…ive paths Fix mixed path separators in env files on Windows - Before: $HOME/.vite-plus\bin (mixed) - After: $HOME/.vite-plus/bin (consistent) Simplify completion generation with loop-based approach
…dows - Increase stack size to 8MB on Windows - Set RUST_MIN_STACK to 8MB in CI test jobs Cargo test default (2MB) are insufficient for deep recursion in clap_complete::generate(). This causes stack overflow when generating shell completion scripts during tests.
0d02ce0 to
9fb37ec
Compare
The forward/backward slash path issue in __vp_bin has been addressed in this PR. # .vite-plus/env
__vp_bin="$HOME/.vite-plus/bin"# .vite-plus/env.ps1
$__vp_bin = "C:\Users\nekomoyi\.vite-plus\bin" |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 444eabb7bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then | ||
| # Zsh shell with completion support | ||
| __vp_completion="__VP_COMPLETION_ZSH__" | ||
| if [ -f "$__vp_completion" ]; then | ||
| . "$__vp_completion" |
There was a problem hiding this comment.
Defer zsh completion registration until
compinit is ready
This only sources _vp when compdef is already defined. In many real .zshrc setups, ~/.vite-plus/env is sourced before compinit runs (for example, before oh-my-zsh.sh), and the zsh docs explicitly place compdef registration after compinit. In that ordering this branch no-ops and nothing retries later, so vp completion never becomes available even though setup succeeded.
Useful? React with 👍 / 👎.
| # Shell completion for fish | ||
| set -l __vp_completion "__VP_COMPLETION_FISH__" | ||
| if test -f "$__vp_completion" | ||
| source "$__vp_completion" |
There was a problem hiding this comment.
Avoid re-adding fish completions every time
env.fish is sourced
env.fish now unconditionally re-sources the generated vp.fish script. Fish's complete builtin adds definitions on top of existing ones when called multiple times, and clap_complete's generated fish script does not clear prior entries first, so any common reload flow like source ~/.config/fish/config.fish or source ~/.vite-plus/env.fish will duplicate every vp completion item in the current session.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 444eabb7bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then | ||
| # Zsh shell with completion support | ||
| __vp_completion="__VP_COMPLETION_ZSH__" | ||
| if [ -f "$__vp_completion" ]; then | ||
| . "$__vp_completion" |
There was a problem hiding this comment.
Defer zsh completion registration until
compinit is ready
This only sources _vp when compdef is already defined. In many real .zshrc setups, ~/.vite-plus/env is sourced before compinit runs (for example, before oh-my-zsh.sh), and the zsh docs explicitly place compdef registration after compinit. In that ordering this branch no-ops and nothing retries later, so vp completion never becomes available even though setup succeeded.
Useful? React with 👍 / 👎.
| # Shell completion for fish | ||
| set -l __vp_completion "__VP_COMPLETION_FISH__" | ||
| if test -f "$__vp_completion" | ||
| source "$__vp_completion" |
There was a problem hiding this comment.
Avoid re-adding fish completions every time
env.fish is sourced
env.fish now unconditionally re-sources the generated vp.fish script. Fish's complete builtin adds definitions on top of existing ones when called multiple times, and clap_complete's generated fish script does not clear prior entries first, so any common reload flow like source ~/.config/fish/config.fish or source ~/.vite-plus/env.fish will duplicate every vp completion item in the current session.
Useful? React with 👍 / 👎.
|
@nekomoyi There is a problem with the automatic suggestions for subcommands, for example, vp build
zsh: do you wish to see all 3976 possibilities (1999 lines)? |
|
@fengmk2 I tried to reproduce the problem on my side but couldn't replicate it. When I type |
Summary
Implements shell completion for the vp CLI.
Changes
Completion scripts for bash, zsh, fish, and PowerShell are generated in
~/.vite-plus/completion/when runningvp env setup, and automatically sourced in the respective env files.Fixes
Fixed mixed path separators in env files on Windows to use forward slashes consistently for
$HOME-relative pathsIncreased stack size to 8MB to handle deep recursion in
clap_complete::generate()which exceeds Windows' default stack size.Closes #950